package com.ssy.lingxi.after.sale.controller;

import com.ssy.lingxi.after.sale.api.model.constant.AgentFlagEnum;
import com.ssy.lingxi.after.sale.api.model.vo.request.CommonIdVO;
import com.ssy.lingxi.after.sale.api.model.vo.request.VerifyVO;
import com.ssy.lingxi.after.sale.model.vo.request.*;
import com.ssy.lingxi.after.sale.model.vo.response.*;
import com.ssy.lingxi.after.sale.service.*;
import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.model.dto.UserLoginCacheDTO;
import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

/**
 * @menu 售后能力-售后换货
 * @author 伍将
 * @date 2020/9/11
 * @version 2.0.0
 * @desc: 售后换货工作流概况
 *  包含5个工作流：(1个内部，4个外部)
 *  内部：换货内部审核工作流
 *  外部(4个)：普通订单[1.正常，2.手工],
 *            合同订单[3.正常，4.手工]
 */
@RestController
@RequestMapping("/as/replaceGoods")
public class ReplaceGoodsController extends BaseController {

    @Resource
    private IReplaceGoodsService replaceService;

    @Resource
    private IReplaceGoodsDetailService replaceGoodsDetailService;

    @Resource
    private IInnerWorkflowRecordService innerWorkflowRecordService;

    @Resource
    private IOuterWorkflowRecordService outerWorkflowRecordService;

    @Resource
    private IReplaceDeliveryGoodsService replaceDeliveryGoodsService;

    /**
     * 售后换货申请-换货申请单查询-分页查询换货申请
     * @author 伍将
     * @date 2020/9/11
     **/
    @RequestMapping(value = "/pageByConsumer", method = RequestMethod.GET)
    public Wrapper<PageData<ReplaceGoodsQueryVO>> pageByConsumer(HttpServletRequest httpRequest, @Valid ReplaceGoodsPageVO pageVO) {
        return replaceService.pageByConsumer(getSysUser(httpRequest), pageVO);
    }

    /**
     * 售后换货申请-换货申请单查询-分页查询换货申请-im
     * @author ds
     * @date 2020/4/22
     **/
    @RequestMapping(value = "/pageByIM", method = RequestMethod.GET)
    public Wrapper<PageData<AfterSaleGoodsIMQueryVO>> pageByIM(HttpServletRequest httpRequest, @Valid AfterSaleGoodsIMPageVO pageVO) {
        return replaceService.pageByIM(getSysUser(httpRequest), pageVO);
    }

    /**
     * 售后换货申请-查询换货申请详情
     * @author 伍将
     * @date 2020/9/11
     **/
    @RequestMapping(value = "/getDetailByConsumer", method = RequestMethod.GET)
    public Wrapper<ReplaceGoodsDetailVO> getDetailByConsumer(HttpServletRequest httpRequest, Long replaceId) {
        return replaceService.getDetailByConsumer(getSysUser(httpRequest), replaceId);
    }

    /**
     * 售后换货-换货详情-分页查询换货商品
     * @author 伍将
     * @date 2020/9/11
     **/
    @RequestMapping(value = "/pageReturnedGoods", method = RequestMethod.GET)
    public Wrapper<PageData<ReplaceGoodsDetailQueryVO>> pageReturnedGoods(HttpServletRequest httpRequest,@Valid ReplaceGoodsDetailPageVO pageVO) {
        return replaceGoodsDetailService.pageList(getSysUser(httpRequest),pageVO);
    }

    /**
     * 售后换货申请-待提交换货申请单-分页查询换货申请
     * @author 伍将
     * @date 2020/9/11
     **/
    @RequestMapping(value = "/pageToBeSubmitByConsumer", method = RequestMethod.GET)
    public Wrapper<PageData<ReplaceGoodsQueryVO>> pageToBeSubmitByConsumer(HttpServletRequest httpRequest, @Valid ReplaceGoodsPageVO pageVO) {
        return replaceService.pageToBeSubmitByConsumer(getSysUser(httpRequest), pageVO);
    }

    /**
     * 售后换货申请-待提交换货申请单-提交换货申请单-新增/修改换货申请
     * @author 伍将
     * @date 2020/9/11
     **/
    @RequestMapping("/save")
    public Wrapper<Long> save(HttpServletRequest httpRequest, @RequestBody @Valid ReplaceGoodsSaveVO saveVO) {
        return replaceService.save(getSysUser(httpRequest), saveVO);
    }

    /**
     * 售后代客换货申请-待提交换货申请单-提交换货申请单-新增/修改换货申请
     * @author 彭冬冬
     * @date 2021/11/25
     * @param httpRequest 请求
     * @param saveVO 保存代客换货VO
     * @return 换货申请id
     */
    @RequestMapping("/agent/save")
    public Wrapper<Long> agentSave(HttpServletRequest httpRequest, @RequestBody @Valid ReplaceGoodsAgentSaveVO saveVO) {
        UserLoginCacheDTO user = buildAgentUser(httpRequest, saveVO);
        saveVO.setAgentFlag(AgentFlagEnum.YES.getCode());
        return replaceService.save(user, saveVO);
    }

    /**
     * 构建代客用户
     * @author 彭冬冬
     * @date 2021/11/25
     * @param httpRequest 请求
     * @param saveVO 保存代客换货VO
     * @return 代客用户
     */
    private UserLoginCacheDTO buildAgentUser(HttpServletRequest httpRequest, ReplaceGoodsAgentSaveVO saveVO) {
        // 校验
        getSysUser(httpRequest);
        // 创建
        UserLoginCacheDTO user = new UserLoginCacheDTO();
        user.setMemberId(saveVO.getMemberId());
        user.setMemberRoleId(saveVO.getMemberRoleId());
        user.setCompany(saveVO.getCompany());
        return user;
    }

    /**
     * 售后换货申请-待提交换货申请单-删除换货申请
     * @author 伍将
     * @date 2020/9/11
     **/
    @RequestMapping("/delete")
    public Wrapper<Void> delete(HttpServletRequest httpRequest, @RequestBody @Valid CommonIdVO commonIdVO) {
        return replaceService.delete(getSysUser(httpRequest), commonIdVO.getDataId());
    }

    /**
     * 售后换货申请-待提交换货申请单-提交换货申请单-提交
     * @author 伍将
     * @date 2020/9/11
     **/
    @RequestMapping("/submit")
    public Wrapper<Void> submit(HttpServletRequest httpRequest, @RequestBody @Valid CommonIdVO commonIdVO) {
        return replaceService.submit(getSysUser(httpRequest), commonIdVO.getDataId());
    }

    /**
     * 售后退货申请-待新增退货发货单-新增退货发货单
     * @author 伍将
     * @date 2020/9/24
     **/
    @RequestMapping("/addReturnDeliveryGoods")
    public Wrapper<Long> addReturnDeliveryGoods(HttpServletRequest httpRequest,@RequestBody @Valid ReplaceDeliveryGoodsAddVO addVO) {
        return replaceService.addReturnDeliveryGoods(getSysUser(httpRequest),addVO);
    }

    /**
     * 售后换货申请-待新增退货发货单-分页查询换货申请
     * @author 伍将
     * @date 2020/9/17
     **/
    @RequestMapping(value = "/pageToBeAddReturnDeliveryGoods", method = RequestMethod.GET)
    public Wrapper<PageData<ReplaceGoodsQueryVO>> pageToBeAddReturnDeliveryGoods(HttpServletRequest httpRequest, @Valid ReplaceGoodsPageVO pageVO) {
        return replaceService.pageToBeAddReturnDeliveryGoods(getSysUser(httpRequest), pageVO);
    }

    /**
     *  售后换货申请-待新增退货发货单-详情
     * @date 2021/8/13
     */
    @RequestMapping(value = "/getReturnDeliveryGoodsDetail", method = RequestMethod.GET)
    public Wrapper<ReplaceGoodsBatchDetailVO> getReturnDeliveryGoodsDetail(HttpServletRequest httpRequest,Long returnDeliveryId) {
        return replaceService.getReturnGoodsDeliveryOrReceiveDetail(getSysUser(httpRequest), returnDeliveryId,false);
    }

    /**
     * 售后换货申请-待新增退货发货单-审核退货发货单
     * @author 伍将
     * @date 2020/9/17
     **/
    @RequestMapping("/verifyReturnDeliveryGoods")
    public Wrapper<Void> verifyReturnDeliveryGoods(HttpServletRequest httpRequest, @RequestBody @Valid CommonIdVO commonIdVO) {
        return replaceService.verifyReturnDeliveryGoodsByConsumer(getSysUser(httpRequest), commonIdVO.getDataId());
    }

    /**
     * 售后换货申请-待新增物流单-分页查询换货申请
     * @author 伍将
     * @date 2020/9/18
     **/
    @RequestMapping(value = "/pageToBeAddLogisticsByConsumer", method = RequestMethod.GET)
    public Wrapper<PageData<ReplaceGoodsQueryVO>> pageToBeAddLogisticsByConsumer(HttpServletRequest httpRequest, @Valid ReplaceGoodsPageVO pageVO) {
        return replaceService.pageToBeAddLogisticsByConsumer(getSysUser(httpRequest), pageVO);
    }

    /**
     * 售后换货申请-待退货发货单-分页查询换货申请
     * @author 伍将
     * @date 2020/9/18
     **/
    @RequestMapping(value = "/pageToBeReturnDeliveryGoods", method = RequestMethod.GET)
    public Wrapper<PageData<ReplaceGoodsQueryVO>> pageToBeReturnDeliveryGoods(HttpServletRequest httpRequest, @Valid ReplaceGoodsPageVO pageVO) {
        return replaceService.pageToBeReturnDeliveryGoods(getSysUser(httpRequest), pageVO);
    }

    /**
     * 售后换货申请-待退货发货单-确认退货发货
     * @author 伍将
     * @date 2020/9/18
     **/
    @RequestMapping("/confirmReturnDeliveryGoods")
    public Wrapper<Void> confirmReturnDeliveryGoods(HttpServletRequest httpRequest, @RequestBody @Valid CommonIdVO commonIdVO) {
        return replaceService.confirmReturnDeliveryGoods(getSysUser(httpRequest), commonIdVO.getDataId());
    }

    /**
     * 售后换货申请-待退货发货单-手工退货发货[新][已调整兼容手工多次:731]
     * @author 伍将
     * @date 2020/12/4
     **/
    @RequestMapping("/manualReturnDeliveryGoods")
    public Wrapper<Void> manualReturnDeliveryGoods(HttpServletRequest httpRequest, @RequestBody @Valid ManualDeliveryGoodsVO deliveryGoodsVO) {
        return replaceService.manualReturnDeliveryGoods(getSysUser(httpRequest), deliveryGoodsVO);
    }

    /**
     * 售后换货申请-待确认退货回单-分页查询换货申请
     * @author 伍将
     * @date 2020/9/18
     **/
    @RequestMapping(value = "/pageToBeConfirmReturnGoodsReceipt", method = RequestMethod.GET)
    public Wrapper<PageData<ReplaceGoodsQueryVO>> pageToBeConfirmReturnGoodsReceipt(HttpServletRequest httpRequest, @Valid ReplaceGoodsPageVO pageVO) {
        return replaceService.pageToBeConfirmReturnGoodsReceipt(getSysUser(httpRequest), pageVO);
    }

    /**
     * 售后换货申请-待确认退货回单-确认退货回单
     * @author 伍将
     * @date 2020/9/18
     **/
    @RequestMapping("/confirmReturnGoodsReceipt")
    public Wrapper<Void> confirmReturnGoodsReceipt(HttpServletRequest httpRequest, @RequestBody @Valid CommonIdVO commonIdVO) {
        return replaceService.confirmReturnGoodsReceipt(getSysUser(httpRequest), commonIdVO.getDataId());
    }

    /**
     * 售后换货申请-待确认退货回单-继续退货发货[废弃]
     * @author 伍将
     * @date 2020/12/3
     **/
    //@RequestMapping("/continueReturnDeliveryGoods")
    public Wrapper<Void> continueReturnDeliveryGoods(HttpServletRequest httpRequest, @RequestBody @Valid CommonIdVO commonIdVO) {
        return replaceService.continueReturnDeliveryGoods(getSysUser(httpRequest), commonIdVO.getDataId());
    }

    /**
     * 售后换货申请-待确认退货回单-确认全部退货回单[废弃]
     * @author 伍将
     * @date 2020/9/22
     **/
    //@RequestMapping("/confirmAllReturnGoodsReceipt")
    public Wrapper<Void> confirmAllReturnGoodsReceipt(HttpServletRequest httpRequest, @RequestBody @Valid CommonIdVO commonIdVO) {
        return replaceService.confirmAllReturnGoodsReceipt(getSysUser(httpRequest), commonIdVO.getDataId());
    }

    /**
     * 售后换货申请-待新增换货入库单-新增换货收货单
     * @author 伍将
     * @date 2020/9/18
     **/
    @RequestMapping("/addReplaceGoodsStorage")
    public Wrapper<Void> addReplaceGoodsStorage(HttpServletRequest httpRequest,@RequestBody @Valid ReplaceReturnReceiveAddVO addVO) {
        return replaceService.addReplaceGoodsStorage(getSysUser(httpRequest),addVO);
    }


    /**
     * 售后换货申请-待新增换货入库单-分页查询换货申请
     * @author 伍将
     * @date 2020/9/18
     **/
    @RequestMapping(value = "/pageToBeAddReplaceGoodsStorage", method = RequestMethod.GET)
    public Wrapper<PageData<ReplaceGoodsQueryVO>> pageToBeAddReplaceGoodsStorage(HttpServletRequest httpRequest, @Valid ReplaceGoodsPageVO pageVO) {
        return replaceService.pageToBeAddReplaceGoodsStorage(getSysUser(httpRequest), pageVO);
    }

    /**
     *  售后换货申请-待新增换货入库单-详情
     * @date 2021/8/13
     * @version 2.0.0
     */
    @RequestMapping(value = "/getReplaceGoodsStorageDetail", method = RequestMethod.GET)
    public Wrapper<ReplaceGoodsBatchDetailVO> getReplaceGoodsStorageDetail(HttpServletRequest httpRequest,Long replaceDeliveryId) {
        return replaceService.getReturnGoodsDeliveryOrReceiveDetail(getSysUser(httpRequest), replaceDeliveryId,false);
    }

    /**
     * 售后换货申请-待新增换货入库单-审核换货收货
     * @author 伍将
     * @date 2020/9/18
     **/
    @RequestMapping("/verifyReplaceGoodsStorage")
    public Wrapper<Void> verifyReplaceGoodsStorage(HttpServletRequest httpRequest, @RequestBody @Valid CommonIdVO commonIdVO) {
        return replaceService.verifyReplaceGoodsStorageByConsumer(getSysUser(httpRequest), commonIdVO.getDataId());
    }

    /**
     * 售后换货申请-待换货收货-分页查询换货申请
     * @author 伍将
     * @date 2020/9/18
     **/
    @RequestMapping(value = "/pageToBeReplaceReceiveGoods", method = RequestMethod.GET)
    public Wrapper<PageData<ReplaceGoodsQueryVO>> pageToBeReplaceReceiveGoods(HttpServletRequest httpRequest, @Valid ReplaceGoodsPageVO pageVO) {
        return replaceService.pageToBeReplaceReceiveGoods(getSysUser(httpRequest), pageVO);
    }

    /**
     * 售后换货申请-待换货收货-确认换货收货
     * @author 伍将
     * @date 2020/9/18
     **/
    @RequestMapping("/confirmReplaceReceiveGoods")
    public Wrapper<Void> confirmReplaceReceiveGoods(HttpServletRequest httpRequest, @RequestBody @Valid CommonIdVO commonIdVO) {
        return replaceService.confirmReplaceReceiveGoods(getSysUser(httpRequest), commonIdVO.getDataId());
    }

    /**
     * 售后换货申请-待换货收货-确认手工换货收货[废弃：统一调用confirmReplaceReceiveGoods]
     * @author 伍将
     * @date 2020/9/18
     **/
    //@RequestMapping("/confirmManualReplaceReceiveGoods")
    public Wrapper<Void> confirmManualReplaceReceiveGoods(HttpServletRequest httpRequest, @RequestBody @Valid CommonIdVO commonIdVO) {
        return replaceService.confirmManualReplaceReceiveGoods(getSysUser(httpRequest), commonIdVO.getDataId());
    }

    /**
     * 售后换货申请-待确认售后完成-分页查询换货申请
     * @author 伍将
     * @date 2020/9/18
     **/
    @RequestMapping(value = "/pageToBeComplete", method = RequestMethod.GET)
    public Wrapper<PageData<ReplaceGoodsQueryVO>> pageToBeComplete(HttpServletRequest httpRequest, @Valid ReplaceGoodsPageVO pageVO) {
        return replaceService.pageToBeComplete(getSysUser(httpRequest), pageVO);
    }

    /**
     * 售后换货申请-待确认售后完成-确认售后完成
     * @author 伍将
     * @date 2020/9/18
     **/
    @RequestMapping("/confirmComplete")
    public Wrapper<Void> confirmComplete(HttpServletRequest httpRequest, @RequestBody @Valid ReplaceConfirmCompleteVO completeVO) {
        return replaceService.confirmComplete(getSysUser(httpRequest), completeVO);
    }

    /***************************分割线，以下是：换货处理*************************/

    /**
     * 售后换货处理-换货申请单查询-分页查询换货申请
     * @author 伍将
     * @date 2020/9/11
     **/
    @RequestMapping(value = "/pageBySupplier", method = RequestMethod.GET)
    public Wrapper<PageData<ReplaceGoodsQueryVO>> pageBySupplier(HttpServletRequest httpRequest, @Valid ReplaceGoodsPageVO pageVO) {
        return replaceService.pageBySupplier(getSysUser(httpRequest), pageVO);
    }

    /**
     * 售后换货处理-查询换货申请详情
     * @author 伍将
     * @date 2020/9/11
     **/
    @RequestMapping(value = "/getDetailBySupplier", method = RequestMethod.GET)
    public Wrapper<ReplaceGoodsDetailVO> getDetailBySupplier(HttpServletRequest httpRequest, Long replaceId) {
        return replaceService.getDetailBySupplier(getSysUser(httpRequest), replaceId);
    }

    /**
     * 售后换货处理-待提交换货申请单-分页查询换货申请
     * @author 伍将
     * @date 2020/9/11
     **/
    @RequestMapping(value = "/pageToBeSubmitBySupplier", method = RequestMethod.GET)
    public Wrapper<PageData<ReplaceGoodsQueryVO>> pageToBeSubmitBySupplier(HttpServletRequest httpRequest, @Valid ReplaceGoodsPageVO pageVO) {
        return replaceService.pageToBeSubmitBySupplier(getSysUser(httpRequest), pageVO);
    }

    /**
     * 售后换货处理-待提交审核换货申请单-设置需要退货
     * @author 伍将
     * @date 2020/9/16
     **/
    @RequestMapping("/setNeedReturnGoods")
    public Wrapper<Void> setNeedReturnGoods(HttpServletRequest httpRequest, @RequestBody @Valid ReplaceGoodsDetailSetStatusVO setStatusVO) {
        return replaceGoodsDetailService.setNeedReturnGoods(getSysUser(httpRequest), setStatusVO);
    }

    /**
     * 售后换货处理-待提交审核换货申请单-提交审核换货申请
     * @author 伍将
     * @date 2020/9/11
     **/
    @RequestMapping("/submitVerify")
    public Wrapper<Void> submitVerify(HttpServletRequest httpRequest, @RequestBody @Valid ReplaceSubmitVerifyVO verifyVO) {
        return replaceService.submitVerify(getSysUser(httpRequest), verifyVO);
    }

    /**
     * 售后换货处理-待审核换货申请单(一级)-分页查询换货申请
     * @author 伍将
     * @date 2020/9/11
     **/
    @RequestMapping(value = "/pageToBeVerifyStepOne", method = RequestMethod.GET)
    public Wrapper<PageData<ReplaceGoodsQueryVO>> pageToBeVerifyStepOne(HttpServletRequest httpRequest, @Valid ReplaceGoodsPageVO pageVO) {
        return replaceService.pageToBeVerifyStepOne(getSysUser(httpRequest), pageVO);
    }

    /**
     * 售后换货处理-待审核换货申请单(一级)-审核换货申请
     * @author 伍将
     * @date 2020/9/16
     **/
    @RequestMapping("/verifyStepOne")
    public Wrapper<Void> verifyStepOne(HttpServletRequest httpRequest, @RequestBody @Valid VerifyVO verifyVO) {
        return replaceService.verifyStepOne(getSysUser(httpRequest), verifyVO);
    }

    /**
     * 售后换货处理-待审核换货申请单(二级)-分页查询换货申请
     * @author 伍将
     * @date 2020/9/11
     **/
    @RequestMapping(value = "/pageToBeVerifyStepTwo", method = RequestMethod.GET)
    public Wrapper<PageData<ReplaceGoodsQueryVO>> pageToBeVerifyStepTwo(HttpServletRequest httpRequest, @Valid ReplaceGoodsPageVO pageVO) {
        return replaceService.pageToBeVerifyStepTwo(getSysUser(httpRequest), pageVO);
    }

    /**
     * 售后换货处理-待审核换货申请单(二级)-审核换货申请
     * @author 伍将
     * @date 2020/9/16
     **/
    @RequestMapping("/verifyStepTwo")
    public Wrapper<Void> verifyStepTwo(HttpServletRequest httpRequest, @RequestBody @Valid VerifyVO verifyVO) {
        return replaceService.verifyStepTwo(getSysUser(httpRequest), verifyVO);
    }

    /**
     * 售后换货处理-待确认换货申请单-分页查询换货申请
     * @author 伍将
     * @date 2020/9/11
     **/
    @RequestMapping(value = "/pageToBeConfirmVerify", method = RequestMethod.GET)
    public Wrapper<PageData<ReplaceGoodsQueryVO>> pageToBeConfirmVerify(HttpServletRequest httpRequest, @Valid ReplaceGoodsPageVO pageVO) {
        return replaceService.pageToBeConfirmVerify(getSysUser(httpRequest), pageVO);
    }

    /**
     * 售后换货处理-待确认换货申请单-确认审核换货申请
     * @author 伍将
     * @date 2020/9/11
     **/
    @RequestMapping("/confirmVerify")
    public Wrapper<Void> confirmVerify(HttpServletRequest httpRequest, @RequestBody @Valid VerifyVO verifyVO) {
        return replaceService.confirmVerify(getSysUser(httpRequest), verifyVO);
    }

    /**
     * 售后换货处理-待新增退货收货单-分页查询换货申请
     * @author 伍将
     * @date 2020/9/18
     **/
    @RequestMapping(value = "/pageToBeAddReturnGoodsStorage", method = RequestMethod.GET)
    public Wrapper<PageData<ReplaceGoodsQueryVO>> pageToBeAddReturnGoodsStorage(HttpServletRequest httpRequest, @Valid ReplaceGoodsPageVO pageVO) {
        return replaceService.pageToBeAddReturnGoodsStorage(getSysUser(httpRequest), pageVO);
    }

    /**
     *  售后换货处理-待新增退货收货单-详情
     * @date 2021/8/13
     * @version 2.0.0
     */
    @RequestMapping(value = "/getReturnGoodsStorageDetail", method = RequestMethod.GET)
    public Wrapper<ReplaceGoodsBatchDetailVO> getReturnGoodsStorageDetail(HttpServletRequest httpRequest,Long returnDeliveryId) {
        return replaceService.getReturnGoodsDeliveryOrReceiveDetail(getSysUser(httpRequest), returnDeliveryId,true);
    }

    /**
     *  售后退货处理-待新增退货收货单-新增退货收货单
     * @author ds
     * @date 2021/8/13
     * @version 2.0.0
     */
    @RequestMapping("/addReturnGoodsStorage")
    public Wrapper<Void> addReturnGoodsStorage(HttpServletRequest httpRequest,@RequestBody @Valid ReplaceReturnReceiveAddVO addVO) {
        return replaceService.addReturnGoodsStorage(getSysUser(httpRequest),addVO);
    }

    /**
     * 售后换货处理-待新增退货收货单-审核退货入库
     * @author 伍将
     * @date 2020/9/18
     **/
    @RequestMapping("/verifyReturnGoodsStorage")
    public Wrapper<Void> verifyReturnGoodsStorage(HttpServletRequest httpRequest, @RequestBody @Valid CommonIdVO commonIdVO) {
        return replaceService.verifyReturnGoodsStorageBySupplier(getSysUser(httpRequest), commonIdVO.getDataId());
    }

    /**
     * 售后换货处理-待退货收货-分页查询换货申请
     * @author 伍将
     * @date 2020/9/18
     **/
    @RequestMapping(value = "/pageToBeReturnReceiveGoods", method = RequestMethod.GET)
    public Wrapper<PageData<ReplaceGoodsQueryVO>> pageToBeReturnReceiveGoods(HttpServletRequest httpRequest, @Valid ReplaceGoodsPageVO pageVO) {
        return replaceService.pageToBeReturnReceiveGoods(getSysUser(httpRequest), pageVO);
    }

    /**
     * 售后换货处理-待退货收货-确认退货收货[废弃：统一调用confirmManualReturnReceiveGoodsCommon]
     * @author 伍将
     * @date 2020/9/18
     **/
    //@RequestMapping("/confirmReturnReceiveGoods")
    public Wrapper<Void> confirmReturnReceiveGoods(HttpServletRequest httpRequest, @RequestBody @Valid CommonIdVO commonIdVO) {
        return replaceService.confirmReturnReceiveGoods(getSysUser(httpRequest), commonIdVO.getDataId());
    }

    /**
     * 售后换货处理-待退货收货-确认手工退货收货[废弃：统一调用confirmManualReturnReceiveGoodsCommon]
     * @author 伍将
     * @date 2020/12/4
     **/
    //@RequestMapping("/confirmManualReturnReceiveGoods")
    public Wrapper<Void> confirmManualReturnReceiveGoods(HttpServletRequest httpRequest, @RequestBody @Valid CommonIdVO commonIdVO) {
        return replaceService.confirmManualReturnReceiveGoods(getSysUser(httpRequest), commonIdVO.getDataId());
    }

    /**
     * 售后换货处理-待退货收货-确认退货收货[新]
     * @author 伍将
     * @date 2020/9/18
     **/
    @RequestMapping("/confirmReturnReceiveGoods")
    public Wrapper<Void> confirmManualReturnReceiveGoodsCommon(HttpServletRequest httpRequest, @RequestBody @Valid CommonIdVO commonIdVO) {
        return replaceService.confirmManualReturnReceiveGoodsCommon(getSysUser(httpRequest), commonIdVO.getDataId());
    }


    /**
     * 售后换货处理-待新增换货发货单-分页查询换货申请
     * @author 伍将
     * @date 2020/9/18
     **/
    @RequestMapping(value = "/pageToBeAddReplaceDeliveryGoods", method = RequestMethod.GET)
    public Wrapper<PageData<ReplaceGoodsQueryVO>> pageToBeAddReplaceDeliveryGoods(HttpServletRequest httpRequest, @Valid ReplaceGoodsPageVO pageVO) {
        return replaceService.pageToBeAddReplaceDeliveryGoods(getSysUser(httpRequest), pageVO);
    }

    /**
     *  售后换货处理-待新增换货发货单-详情
     * @date 2021/8/13
     * @version 2.0.0
     */
    @RequestMapping(value = "/getReplaceDeliveryGoodsDetail", method = RequestMethod.GET)
    public Wrapper<ReplaceGoodsBatchDetailVO> getReplaceDeliveryGoodsDetail(HttpServletRequest httpRequest,Long replaceDeliveryId) {
        return replaceService.getReturnGoodsDeliveryOrReceiveDetail(getSysUser(httpRequest), replaceDeliveryId,true);
    }

    /**
     * 售后换货处理-待新增换货发货单-新增
     * @author 伍将
     * @date 2020/9/17
     **/
    @RequestMapping(value ="/addReplaceDeliveryGoods", method = RequestMethod.POST)
    public Wrapper<Long> addReplaceDeliveryGoods(HttpServletRequest httpRequest,@RequestBody @Valid ReplaceAddDeliveryGoodsVO addVO) {
        return replaceService.addReplaceDeliveryGoods(getSysUser(httpRequest),addVO);
    }

    /**
     * 售后换货处理-待新增换货发货单-审核换货发货单
     * @author 伍将
     * @date 2020/9/18
     **/
    @RequestMapping("/verifyReplaceDeliveryGoods")
    public Wrapper<Void> verifyReplaceDeliveryGoods(HttpServletRequest httpRequest, @RequestBody @Valid CommonIdVO commonIdVO) {
        return replaceService.verifyReplaceDeliveryGoodsBySupplier(getSysUser(httpRequest), commonIdVO.getDataId());
    }

    /**
     * 售后换货处理-待新增物流单-分页查询换货申请
     * @author 伍将
     * @date 2020/9/18
     **/
    @RequestMapping(value = "/pageToBeAddLogisticsBySupplier", method = RequestMethod.GET)
    public Wrapper<PageData<ReplaceGoodsQueryVO>> pageToBeAddLogisticsBySupplier(HttpServletRequest httpRequest, @Valid ReplaceGoodsPageVO pageVO) {
        return replaceService.pageToBeAddLogisticsBySupplier(getSysUser(httpRequest), pageVO);
    }

    /**
     * 售后换货处理-待换货发货-分页查询换货申请
     * @author 伍将
     * @date 2020/9/18
     **/
    @RequestMapping(value = "/pageToBeReplaceDeliveryGoods", method = RequestMethod.GET)
    public Wrapper<PageData<ReplaceGoodsQueryVO>> pageToBeReplaceDeliveryGoods(HttpServletRequest httpRequest, @Valid ReplaceGoodsPageVO pageVO) {
        return replaceService.pageToBeReplaceDeliveryGoods(getSysUser(httpRequest), pageVO);
    }

    /**
     * 售后换货处理-待换货发货单-确认换货发货
     * @author 伍将
     * @date 2020/9/18
     **/
    @RequestMapping("/confirmReplaceDeliveryGoods")
    public Wrapper<Void> confirmReplaceDeliveryGoods(HttpServletRequest httpRequest, @RequestBody @Valid CommonIdVO commonIdVO) {
        return replaceService.confirmReplaceDeliveryGoods(getSysUser(httpRequest), commonIdVO.getDataId());
    }

    /**
     * 售后换货处理-待换货发货单-手工换货发货[废弃]
     * @author 伍将
     * @date 2020/12/4
     **/
    //@RequestMapping("/manualReplaceDeliveryGoods")
    public Wrapper<Void> manualReplaceDeliveryGoods(HttpServletRequest httpRequest, @RequestBody @Valid ManualDeliveryGoodsVO deliveryGoodsVO) {
        return replaceService.manualReplaceDeliveryGoods(getSysUser(httpRequest), deliveryGoodsVO);
    }

    /**
     * 售后换货处理-待换货发货单-手工换货发货
     * @author 伍将
     * @date 2020/12/4
     **/
    @RequestMapping("/manualReplaceDeliveryGoods")
    public Wrapper<Void> manualReplaceDeliveryGoodsCommon(HttpServletRequest httpRequest, @RequestBody @Valid ManualDeliveryGoodsAddVO deliveryGoodsVO) {
        return replaceService.manualReplaceDeliveryGoodsCommon(getSysUser(httpRequest), deliveryGoodsVO);
    }

    /**
     * 售后换货处理-待确认换货回单-分页查询换货申请
     * @author 伍将
     * @date 2020/9/18
     **/
    @RequestMapping(value = "/pageToBeConfirmReplaceGoodsReceipt", method = RequestMethod.GET)
    public Wrapper<PageData<ReplaceGoodsQueryVO>> pageToBeConfirmReplaceGoodsReceipt(HttpServletRequest httpRequest, @Valid ReplaceGoodsPageVO pageVO) {
        return replaceService.pageToBeConfirmReplaceGoodsReceipt(getSysUser(httpRequest), pageVO);
    }

    /**
     * 售后换货处理-待确认换货回单-确认换货回单
     * @author 伍将
     * @date 2020/9/18
     **/
    @RequestMapping("/confirmReplaceGoodsReceipt")
    public Wrapper<Void> confirmReplaceGoodsReceipt(HttpServletRequest httpRequest, @RequestBody @Valid CommonIdVO commonIdVO) {
        return replaceService.confirmReplaceGoodsReceipt(getSysUser(httpRequest), commonIdVO.getDataId());
    }

    /**
     * 售后换货处理-待确认换货回单-继续换货发货[废弃]
     * @author 伍将
     * @date 2020/12/3
     **/
    //@RequestMapping("/continueReplaceDeliveryGoods")
    public Wrapper<Void> continueReplaceDeliveryGoods(HttpServletRequest httpRequest, @RequestBody @Valid CommonIdVO commonIdVO) {
        return replaceService.continueReplaceDeliveryGoods(getSysUser(httpRequest), commonIdVO.getDataId());
    }

    /**
     * 售后换货处理-待确认换货回单-确认所有换货回单[废弃]
     * @author 伍将
     * @date 2020/9/22
     **/
    //@RequestMapping("/confirmAllReplaceGoodsReceipt")
    public Wrapper<Void> confirmAllReplaceGoodsReceipt(HttpServletRequest httpRequest, @RequestBody @Valid CommonIdVO commonIdVO) {
        return replaceService.confirmAllReplaceGoodsReceipt(getSysUser(httpRequest), commonIdVO.getDataId());
    }

    /**
     * 售后换货处理-换货申请单查询-中止售后
     * @author 伍将
     * @date 2020/9/24
     **/
    @RequestMapping("/stopReturnGoods")
    public Wrapper<Void> stopReturnGoods(HttpServletRequest httpRequest, @RequestBody @Valid ReplaceGoodsStopVO stopVO) {
        return replaceService.stopReturnGoods(getSysUser(httpRequest), stopVO);
    }

    /**
     * 分页查询列表页面搜索条件内容
     * @author 伍将
     * @date 2020/10/17
     **/
    @RequestMapping(value = "/pageItems", method = RequestMethod.GET)
    public Wrapper<ReplaceGoodsPageItemsVO> pageItems(HttpServletRequest httpRequest) {
        return replaceService.pageItems(getSysUser(httpRequest));
    }

    /**
     * 分页查询内部流转记录
     * @author 伍将
     * @date 2020/10/19
     * @param httpRequest:
     * @param pageVO:
     * @return com.ssy.lingxi.common.response.Wrapper<com.ssy.lingxi.common.response.PageData < com.ssy.lingxi.after.sale.model.vo.response.InnerWorkflowRecordVO>>
     **/
    @RequestMapping(value = "/pageInnerWorkflowRecord", method = RequestMethod.GET)
    public Wrapper<PageData<ReplaceInnerWorkflowRecordVO>> pageInnerWorkflowRecord(HttpServletRequest httpRequest, @Valid WorkflowPageVO pageVO) {
        return innerWorkflowRecordService.pageReplaceRecord(getSysUser(httpRequest), pageVO);
    }

    /**
     * 分页查询外部流转记录
     * @author 伍将
     * @date 2020/10/19
     * @param httpRequest:
     * @param pageVO:
     * @return com.ssy.lingxi.common.response.Wrapper<com.ssy.lingxi.common.response.PageData < com.ssy.lingxi.after.sale.model.vo.response.InnerWorkflowRecordVO>>
     **/
    @RequestMapping(value = "/pageOuterWorkflowRecord", method = RequestMethod.GET)
    public Wrapper<PageData<ReplaceOuterWorkflowRecordVO>> pageOuterWorkflowRecord(HttpServletRequest httpRequest, @Valid WorkflowPageVO pageVO) {
        return outerWorkflowRecordService.pageReplaceRecord(getSysUser(httpRequest), pageVO);
    }

    /**
     * 平台后台-换货申请单管理-分页查询换货申请
     * @author 伍将
     * @date 2020/12/7
     **/
    @RequestMapping(value = "/pageByPlatform", method = RequestMethod.GET)
    public Wrapper<PageData<ReplaceGoodsQueryVO>> pageByPlatform(HttpServletRequest httpRequest, @Valid ReplaceGoodsPageVO pageVO) {
        return replaceService.pageByPlatform(getSysUser(httpRequest), pageVO);
    }

    /**
     * 平台后台-换货申请单管理-查询换货申请详情
     * @author 伍将
     * @date 2020/12/7
     **/
    @RequestMapping(value = "/getDetailByPlatform", method = RequestMethod.GET)
    public Wrapper<ReplaceGoodsDetailVO> getDetailByPlatform(HttpServletRequest httpRequest, Long replaceId) {
        return replaceService.getDetailByPlatform(getSysUser(httpRequest), replaceId);
    }

    /**
     * 物流服务-获取退货商品
     * @author 伍将
     * @date 2020/12/8
     **/
    @RequestMapping(value = "/pageReturnCommodityByLogistics", method = RequestMethod.GET)
    public Wrapper<PageData<CommodityQueryVO>> pageReturnCommodityByLogistics(@Valid CommodityPageVO pageVO) {
        return replaceDeliveryGoodsService.pageReturnCommodityByLogistics(pageVO);
    }

    /**
     * 物流服务-获取换货商品
     * @author 伍将
     * @date 2020/12/8
     **/
    @RequestMapping(value = "/pageReplaceCommodityByLogistics", method = RequestMethod.GET)
    public Wrapper<PageData<CommodityQueryVO>> pageReplaceCommodityByLogistics(@Valid CommodityPageVO pageVO) {
        return replaceDeliveryGoodsService.pageReplaceCommodityByLogistics(pageVO);
    }

    /**
     * 物流服务-分页获取待新增退货物流申请单
     * @author 伍将
     * @date 2020/12/8
     **/
    @RequestMapping(value = "/pageToBeAddReturnByLogistics", method = RequestMethod.GET)
    public Wrapper<PageData<ApplyOrderQueryVO>> pageToBeAddReturnByLogistics(HttpServletRequest httpRequest, @Valid ApplyOrderPageVO pageVO) {
        return replaceService.pageToBeAddReturnByLogistics(getSysUser(httpRequest), pageVO);
    }

    /**
     * 物流服务-分页获取待新增换货物流申请单
     * @author 伍将
     * @date 2020/12/8
     **/
    @RequestMapping(value = "/pageToBeAddReplaceByLogistics", method = RequestMethod.GET)
    public Wrapper<PageData<ApplyOrderQueryVO>> pageToBeAddReplaceByLogistics(HttpServletRequest httpRequest, @Valid ApplyOrderPageVO pageVO) {
        return replaceService.pageToBeAddReplaceByLogistics(getSysUser(httpRequest), pageVO);
    }

    /**
     * 物流服务-获取退货申请单详情
     * @author 伍将
     * @date 2020/12/9
     **/
    @RequestMapping(value = "/pageReturnDetailByLogistics", method = RequestMethod.GET)
    public Wrapper<ApplyOrderQueryVO> pageReturnDetailByLogistics(Long replaceId) {
        return replaceService.pageReturnDetailByLogistics(replaceId);
    }

    /**
     * 物流服务-获取换货申请单详情
     * @author 伍将
     * @date 2020/12/9
     **/
    @RequestMapping(value = "/pageReplaceDetailByLogistics", method = RequestMethod.GET)
    public Wrapper<ApplyOrderQueryVO> pageReplaceDetailByLogistics(Long replaceId) {
        return replaceService.pageReplaceDetailByLogistics(replaceId);
    }

    /**
     * 仓库服务-分页查询待新增退货发货单
     * @author 伍将
     * @date 2020/12/22
     **/
    @RequestMapping(value = "/pageToBeAddReturnDeliveryByWarehouse", method = RequestMethod.GET)
    public Wrapper<PageData<ReplaceGoodsQueryVO>> pageToBeAddReturnDeliveryByWarehouse(HttpServletRequest httpRequest, @Valid ReplaceGoodsPageVO pageVO) {
        return replaceService.pageToBeAddReturnDeliveryByWarehouse(getSysUser(httpRequest), pageVO);
    }

    /**
     * 仓库服务-分页查询待新增退货收货单
     * @author 伍将
     * @date 2020/12/22
     **/
    @RequestMapping(value = "/pageToBeAddReturnStorageByWarehouse", method = RequestMethod.GET)
    public Wrapper<PageData<ReplaceGoodsQueryVO>> pageToBeAddReturnStorageByWarehouse(HttpServletRequest httpRequest, @Valid ReplaceGoodsPageVO pageVO) {
        return replaceService.pageToBeAddReturnStorageByWarehouse(getSysUser(httpRequest), pageVO);
    }

    /**
     * 仓库服务-分页查询待新增换货发货单
     * @author 伍将
     * @date 2020/12/22
     **/
    @RequestMapping(value = "/pageToBeAddReplaceDeliveryByWarehouse", method = RequestMethod.GET)
    public Wrapper<PageData<ReplaceGoodsQueryVO>> pageToBeAddReplaceDeliveryByWarehouse(HttpServletRequest httpRequest, @Valid ReplaceGoodsPageVO pageVO) {
        return replaceService.pageToBeAddReplaceDeliveryByWarehouse(getSysUser(httpRequest), pageVO);
    }

    /**
     * 仓库服务-分页查询待新增换货收货单
     * @author 伍将
     * @date 2020/12/22
     **/
    @RequestMapping(value = "/pageToBeAddReplaceStorageByWarehouse", method = RequestMethod.GET)
    public Wrapper<PageData<ReplaceGoodsQueryVO>> pageToBeAddReplaceStorageByWarehouse(HttpServletRequest httpRequest, @Valid ReplaceGoodsPageVO pageVO) {
        return replaceService.pageToBeAddReplaceStorageByWarehouse(getSysUser(httpRequest), pageVO);
    }

}
